//
// Created by wyh on 2025-07-15 00:12.
//

#ifndef FRAMEWORK_CPP_PARSER_H
#define FRAMEWORK_CPP_PARSER_H

#include <string>

#include "xml/xml.h"

namespace wyh {
    namespace xml {
        class Parser
        {
        public:
            Parser() = default;
            ~Parser() = default;

            bool load(const std::string &filename);

            bool load(const char *buf, int len);

            Xml parse();

        private:
            void skip_white_space();
            bool parse_declaration();
            bool parse_comment();
            Xml parse_element();
            std::string parse_element_name();
            std::string parse_element_text();
            std::string parse_element_attr_key();
            std::string parse_element_attr_val();


        private:
            std::string m_str;
            int m_idx = 0;
        };
    } // namespace xml
} // namespace wyh

#endif //FRAMEWORK_CPP_PARSER_H
